<?php if (!defined('THINK_PATH')) exit();?><div class="row">
          <div class="col-lg-12">
            <div class="card">
              <div class="card-toolbar clearfix">
                <div class="toolbar-btn-action">
                  <a class="btn btn-primary m-r-5 class_add" href="javascript:void(0)" data-toggle="modal" data-target="#exampleModal" data="" class="class_add"><i class="mdi mdi-plus"></i> 新增分类</a>

                </div>
              </div>
              <div class="card-body">
                
                <div class="table-responsive">
                  <table class="table table-bordered">
                    <thead>
                      <tr>
                        <th class="col-lg-1">编号</th>
                        <th>分类名称</th>
                        <th>子类</th>
                        <th>操作</th>
                      </tr>
                    </thead>
                    <tbody>
                      <?php if(is_array($data)): $i = 0; $__LIST__ = $data;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$v): $mod = ($i % 2 );++$i;?><tr>
                        <td><?php echo ($v["id"]); ?></td>
                        <td><?php echo ($v["class_name"]); ?></td>
                        <td>
<!--<a href="javascript:void(0)" data-toggle="modal" data-target="#exampleModal" data="<?php echo ($v["id"]); ?>" class="class_add">添加子分类</a>-->暂未开放
                        </td>
                        <td>
                          <div class="btn-group">
                            <a data-toggle="modal" data-target="#exampleModal" class="btn btn-xs btn-default class_add" sort="<?php echo ($v["class_sort"]); ?>" zid="<?php echo ($v["id"]); ?>" name="<?php echo ($v["class_name"]); ?>" href="javascript:void(0)"><i class="mdi mdi-pencil"></i></a>
                            <a class="btn btn-xs btn-default delete" href="javascript:void(0)" data="<?php echo ($v["id"]); ?>"><i class="mdi mdi-window-close"></i></a>
                          </div>
                        </td>
                      </tr>
                      <?php $e = M('classify')->where('class_sid='.$v['id'])->select(); ?>
                      <?php if(is_array($e)): $i = 0; $__LIST__ = $e;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$v): $mod = ($i % 2 );++$i;?><tr>
                        <td><?php echo ($v["id"]); ?></td>
                        <td>├─<?php echo ($v["class_name"]); ?></td>
                        <td></td>
                        <td>
                          <div class="btn-group">
                            <a data-toggle="modal" data-target="#exampleModal" class="btn btn-xs btn-default class_add" sort="<?php echo ($v["class_sort"]); ?>" zid="<?php echo ($v["id"]); ?>" name="<?php echo ($v["class_name"]); ?>" href="javascript:void(0)"><i class="mdi mdi-pencil"></i></a>
                            <a class="btn btn-xs btn-default delete" href="javascript:void(0)" data="<?php echo ($v["id"]); ?>"><i class="mdi mdi-window-close"></i></a>
                          </div>
                        </td>
                      </tr><?php endforeach; endif; else: echo "" ;endif; endforeach; endif; else: echo "" ;endif; ?>
                    </tbody>
                  </table>
                </div>
                <ul class="pagination">

                </ul>
       
              </div>
            </div>
          </div>   
</div>
<!--模拟静态框-->
  <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" style="display: none;">
                  <div class="modal-dialog" role="document">
                    <div class="modal-content">
                      <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
                        <h4 class="modal-title" id="exampleModalLabel">分类管理</h4>
                      </div>
                      <div class="modal-body">
                        <form id="add_post"  action="" method="post" onsubmit="return false;">
                          <div class="form-group">
                            <label for="recipient-name" class="control-label">分类名称：</label>
                            <input type="text" class="form-control" name="class_name" id="name">
                          </div>
                          
                          <!--no
                         <div class="form-group">
                            <label for="recipient-name" class="control-label">分类排序：</label>
                            <input placeholder="数值越大越靠前" type="text" class="form-control" name="class_sort" id="sort">
                          </div>-->
                          <input type="hidden" id="sid" name="class_sid">
                          <input type="hidden" id="zid" name="id">
                        </form>
                      </div>
                      <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                        <button type="button" class="btn btn-primary send">提交保存</button>
                      </div>
                    </div>
                  </div>
                </div>
<!--模拟静态框-->
<script>
//添加分类
  $('.class_add').click(function(){
  	$('#sid').val($(this).attr("data"));
    $('#zid').val($(this).attr("zid"));
    $('#name').val($(this).attr("name"));
    $('#sort').val($(this).attr("sort"));
    $('#class_ui').val($(this).attr("class_ui"));
  }); 
//提交添加分类
  $('.send').click(function(){
  lightyear.loading('show');  // 显示
    $.ajax({
    type: "POST",
    url: "<?php echo U('ClassData/class_post');?>",
    data:$('#add_post').serialize(),
      success: function(data){
        if(data.indexOf('操作成功')>=0){
 lightyear.loading('hide');  // 隐藏 
 
     lightyear.notify('操作成功', 'success', 1000, 'mdi mdi-emoticon-happy', 'top', 'center');
        }else{
     lightyear.notify(data, 'danger', 1000);
    }
      }
    });
  });
//删除
  $('.delete').click(function(){
  lightyear.loading('show');  // 显示
    $.ajax({
    type: "POST",
    url: "<?php echo U('ClassData/class_del');?>", 
    data:'id='+$(this).attr("data"), 
      success: function(data){
        if(data.indexOf('操作成功')>=0){
          lightyear.loading('hide');  // 隐藏 
     lightyear.notify('操作成功', 'success', 500, 'mdi mdi-emoticon-happy', 'top', 'center');
     setTimeout(function() {
          $.ajax({
          type: "POST",
          url: "<?php echo U('ClassData/index');?>",       
              success: function(data){
                      if(data){
              $("#content").html(data);
              
            }else{
              alert('页面加载失败或异常,请刷新重试');
              lightyear.loading('hide'); 
            }
              }
          });
          }, 1000);
        }else{
          lightyear.loading('hide');  // 隐藏 
     lightyear.notify(data, 'danger', 1000);
    }
      }
    });
  });
</script>